package com.gwl.controller;

import com.gwl.common.result.R;
import com.gwl.entity.User;
import com.gwl.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author GaoWanli
 * @since 2023/8/12
 */
@RestController
@RequestMapping("/user/")
@Api(tags = "用户")
public class UserController {

    @Resource
    private UserService service;

    @PostMapping("saveOrUpdate")
    @ApiOperation("新增或修改")
    public R saveOrUpdate(@RequestBody User user) {

        return R.ok(service.saveOrUpdate(user));
    }

    @PostMapping("del")
    @ApiOperation("删除")
    public R del(Integer id) {
        return R.ok(service.removeById(id));
    }

    @GetMapping("list")
    @ApiOperation("查询列表")
    public R list() {
        return R.ok(service.list());
    }
}
